-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Angle and Dihedral Restraints #272
Feature Angle and Dihedral Restraints #272
Conversation
… bugs might still be lurking somewhere
… also renamed the core alchemical angle/dihedral restraint c++ files
… also slightly tidied up python API for these restraints
Thanks, @akalpokas. This looks great! I'll go through this during the week in between doing other things. I'll probably do it in chunks, so expect to see comments/suggestions drop in now and then. |
Thanks, @akalpokas, this all looks good. My only thoughts are regarding the functional forms and if we want to support anything different in future. For example, we've had some recent interest in the restricted bending potential from GROMACS. I'm not sure if it makes sense to leave harmonic potentials as the default for |
Hi @lohedges, thanks for your review. I agree that the harmonic potential might not be ideal long term solution. When I was implementing this originally I was wondering if I could implement the restraint in such a way that the functional form would be flexible, i.e. the user could specify the expression for the OpenMM force upon creation of the restraint as one of the arguments. I think it's possible to modify the restraints class so that it has OpenMM expression as a parameter upon construction, sets it to harmonic functional form as default or takes the user specific one instead and uses it during Sire to OpenMM system creation. |
// if (distinct.count() != 3) | ||
// throw SireError::invalid_arg(QObject::tr( | ||
// "There is something wrong with the atoms provided. " | ||
// "They should all be unique and all greater than or equal to 0."), | ||
// CODELOC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More commented code.
I think that could work, but might be in tricky in general since we'd need a way of coupling a parameter in the expression to what's used by the lambda lever. Will have a think. |
@lohedges I have addressed the suggested changes, thanks for the review. Happy for this to be merged! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for this, I'll merge across to my branch and merge to devel
in one-shot.
Introduction
This PR expands the restraints functionality of sire in order to include stand-alone angle and dihedral restraints, which can be used in normal and alchemical simulations within sire. This restraints expansion in theory enables scaffold-hopping & ring-breaking FEP within sire through the use of auxiliary restraints approach (https://pubs.acs.org/doi/10.1021/acs.jctc.1c00214), although this has only been tested for cyclohexane --> hexane transformation. Regardless of whether this is the actual approach we will proceed in the future for scaffold-hopping experiments, expansion of restraints functionality will allow for cross-comparison with other scaffold-hopping methodologies, and further expands the capabilities of sire dynamics.
Proposed Changes
Specifically this PR does the following:
sire_to_openmm_system.cpp
) to create a CustomAngleForce and a CustomTorsionForce based on these restraints. Note that currently the angle and torsion restraint forces are specified and applied in a harmonic functional form. This was done in order to keep consistent with Boresch restraint force implementation, but can be easily changed if needed.lambdalever.cpp
) to allow scaling of the restraints force withrho
- this effectively allows these restraints to be used in alchemical simulations just as any other perturbable restraint.In the end the user can create angle and dihedral restraints in the same manner as other already existing restraints. For example:
or
Because most of the restraints code is adapted from already existing restraints classes, these restraints support the same functionality as others (custom force values, usage of containers for passing atoms, multiple restraints, etc.)
Example Usage
This section showcases angle and dihedral restraints in action for alchemical simulations for a hexane molecule. Please compile the code from this PR as well as BioSimSpace in order to run this code.
Alchemical Angle Restraints
In this example, we are going to restrain the first angle in a hexane molecule to
3 rad
by applying a force of100 kcal mol-1 rad-2
by switching restraints force as a function of lambda (so that restraints are fully on at lambda=1). Please createalchemical_angle_restraints_test
directory before running this test.Setup and Dynamics
Plotting
After the dynamics have concluded, we can visualize the restraint being turned on:
Which gives:

We can see that as lambda is increasing, the average value of the first angle is increasing from around 1.9 rad (equilibrium value is 1.96 rad for this particular angle) to around 2.55 rad.
We can also inspect the openMM system files created in
alchemical_angle_restraints_test
directory to see the CustomAngleForce. E.g. for the first lambda window:Alchemical Dihedral Restraints
In this example, we are going to restrain the first torsion in a hexane molecule to
2 rad
by applying a force of10 kcal mol-1 rad-2
by again switching restraints force as a function of lambda. Please createalchemical_dihedral_restraints_test
directory before running this test.Setup and Dynamics
Plotting
Which gives:

We can see that as the value of lambda increases, the dihedral gets restrained to a value of around 2 rad.
Again we can inspect the
.xml
file to see the force in action:Checklists
devel
into this branch before issuing this pull request (e.g. by runninggit pull origin devel
): [y]Suggested reviewers:
@lohedges
Happy to make further improvements if needed!